<?php include("../common/pdata_mysql.php");
//require("../common/global.php");
$itemdetail = array("itemid"=>0,"iname"=>0,"transnum"=>0,"highvolt"=>0,"midvolt"=>0,"lowvolt"=>0,"transcap"=>0,"highline"=>0,"midline"=>0,"lowline"=>0,"capreactive"=>0,"indreactive"=>0,"starea"=>0,"allbuildarea"=>0,"mainbuildarea"=>0,"remark"=>0,"costjzmain1"=>0,"costjzmain2"=>0,"costjzmain3"=>0,"costjzmain4"=>0,"costjzsp"=>0,"costazmain1"=>0,"costazmain2"=>0,"costazmain3"=>0,"costazmain4"=>0,"costazsp"=>0,"costsbmain1"=>0,"costsbmain2"=>0,"costsbex"=>0,"costclear"=>0,"costother1"=>0,"costother2"=>0,"costother3"=>0,"coststat"=>0,"costdyn"=>0,"remark"=>0,"pid"=>0,"ptid"=>0,"phid"=>0,"frm"=>0,"stid"=>0,"procode"=>0);
//foreach($itemdetail as $value)
//{
//	$value = 0;
//}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>项目更新</title>
<link href="/css/allstyle.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.itembox {
	width: 960px;
	margin: 20px;
}
.doublelengh { width: 838px; }
td label {
	float: left;
	width: 90px;
	margin: 0px;
	list-style-type: none;
	font-size: 12px;
	padding-top: 4px;
	padding-right: 0px;
	padding-bottom: 4px;
	padding-left: 0px;
}
td input {
	float: left;
	width: 200px;
	height: 20px;
	margin: 0px;
	list-style-type: none;
	font-size: 12px;
	padding-top: 4px;
	padding-right: 0px;
	padding-bottom: 4px;
	padding-left: 0px;
}
.inputStyle {
	height: 40px;
	width: 120px;
	float: right;
}
</style>
</head>

<body>
<div id="header">
  <?php include("../common/header.php"); ?>
</div>
<div id="wrap">
    <?php
	if(isset($_REQUEST['modi']) && $_REQUEST['modi']==0)
	{
		$itemdetail["itemid"]=$_REQUEST["itemid"];
		$itemdetail["iname"]=$_REQUEST["iname"];
		$itemdetail["transnum"]=$_REQUEST["transnum"];
		$itemdetail["highvolt"]=$_REQUEST["highvolt"];
		$itemdetail["midvolt"]=$_REQUEST["midvolt"];
		$itemdetail["lowvolt"]=$_REQUEST["lowvolt"];
		$itemdetail["transcap"]=$_REQUEST["transcap"];
		$itemdetail["highline"]=$_REQUEST["highline"];
		$itemdetail["midline"]=$_REQUEST["midline"];
		$itemdetail["lowline"]=$_REQUEST["lowline"];
		$itemdetail["capreactive"]=$_REQUEST["capreactive"];
		$itemdetail["indreactive"]=$_REQUEST["indreactive"];
		$itemdetail["starea"]=$_REQUEST["starea"];
		$itemdetail["allbuildarea"]=$_REQUEST["allbuildarea"];
		$itemdetail["mainbuildarea"]=$_REQUEST["mainbuildarea"];
		$itemdetail["remark"]=$_REQUEST["remark"];
		$itemdetail["costjzmain1"]=$_REQUEST["costjzmain1"];
		$itemdetail["costjzmain2"]=$_REQUEST["costjzmain2"];
		$itemdetail["costjzmain3"]=$_REQUEST["costjzmain3"];
		$itemdetail["costjzmain4"]=$_REQUEST["costjzmain4"];
		$itemdetail["costjzsp"]=$_REQUEST["costjzsp"];
		$itemdetail["costazmain1"]=$_REQUEST["costazmain1"];
		$itemdetail["costazmain2"]=$_REQUEST["costazmain2"];
		$itemdetail["costazmain3"]=$_REQUEST["costazmain3"];
		$itemdetail["costazmain4"]=$_REQUEST["costazmain4"];
		$itemdetail["costazsp"]=$_REQUEST["costazsp"];
		$itemdetail["costsbmain1"]=$_REQUEST["costsbmain1"];
		$itemdetail["costsbmain2"]=$_REQUEST["costsbmain2"];
		$itemdetail["costsbex"]=$_REQUEST["costsbex"];
		$itemdetail["costclear"]=$_REQUEST["costclear"];
		$itemdetail["costother1"]=$_REQUEST["costother1"];
		$itemdetail["costother2"]=$_REQUEST["costother2"];
		$itemdetail["costother3"]=$_REQUEST["costother3"];
		$itemdetail["coststat"]=$_REQUEST["coststat"];
		$itemdetail["costdyn"]=$_REQUEST["costdyn"];
		$itemdetail["remark"]=$_REQUEST["remark"];
		$itemdetail["pid"]=$_REQUEST["pid"];
		$itemdetail["ptid"]=$_REQUEST["ptid"];
		$itemdetail["phid"]=$_REQUEST["phid"];
		$itemdetail["frm"]=$_REQUEST["frm"];
		$itemdetail["stid"]=$_REQUEST["stid"];
		$itemdetail["procode"]=$_REQUEST["procode"];
		
	}
	elseif(isset($_REQUEST['modi']) && $_REQUEST['modi']==1)
	{
		$itemdetail["itemid"]=$_REQUEST["itemid"];
		$itemdetail["iname"]=$_REQUEST["iname"];
		$itemdetail["transnum"]=$_REQUEST["transnum"];
		$itemdetail["highvolt"]=$_REQUEST["highvolt"];
		$itemdetail["midvolt"]=$_REQUEST["midvolt"];
		$itemdetail["lowvolt"]=$_REQUEST["lowvolt"];
		$itemdetail["transcap"]=$_REQUEST["transcap"];
		$itemdetail["highline"]=$_REQUEST["highline"];
		$itemdetail["midline"]=$_REQUEST["midline"];
		$itemdetail["lowline"]=$_REQUEST["lowline"];
		$itemdetail["capreactive"]=$_REQUEST["capreactive"];
		$itemdetail["indreactive"]=$_REQUEST["indreactive"];
		$itemdetail["starea"]=$_REQUEST["starea"];
		$itemdetail["allbuildarea"]=$_REQUEST["allbuildarea"];
		$itemdetail["mainbuildarea"]=$_REQUEST["mainbuildarea"];
		$itemdetail["remark"]=$_REQUEST["remark"];
		$itemdetail["costjzmain1"]=$_REQUEST["costjzmain1"];
		$itemdetail["costjzmain2"]=$_REQUEST["costjzmain2"];
		$itemdetail["costjzmain3"]=$_REQUEST["costjzmain3"];
		$itemdetail["costjzmain4"]=$_REQUEST["costjzmain4"];
		$itemdetail["costjzsp"]=$_REQUEST["costjzsp"];
		$itemdetail["costazmain1"]=$_REQUEST["costazmain1"];
		$itemdetail["costazmain2"]=$_REQUEST["costazmain2"];
		$itemdetail["costazmain3"]=$_REQUEST["costazmain3"];
		$itemdetail["costazmain4"]=$_REQUEST["costazmain4"];
		$itemdetail["costazsp"]=$_REQUEST["costazsp"];
		$itemdetail["costsbmain1"]=$_REQUEST["costsbmain1"];
		$itemdetail["costsbmain2"]=$_REQUEST["costsbmain2"];
		$itemdetail["costsbex"]=$_REQUEST["costsbex"];
		$itemdetail["costclear"]=$_REQUEST["costclear"];
		$itemdetail["costother1"]=$_REQUEST["costother1"];
		$itemdetail["costother2"]=$_REQUEST["costother2"];
		$itemdetail["costother3"]=$_REQUEST["costother3"];
		$itemdetail["coststat"]=$_REQUEST["coststat"];
		$itemdetail["costdyn"]=$_REQUEST["costdyn"];
		$itemdetail["remark"]=$_REQUEST["remark"];
		$itemdetail["pid"]=$_REQUEST["pid"];
		$itemdetail["ptid"]=$_REQUEST["ptid"];
		$itemdetail["phid"]=$_REQUEST["phid"];
		$itemdetail["frm"]=$_REQUEST["frm"];
		$itemdetail["stid"]=$_REQUEST["stid"];
		$itemdetail["procode"]=$_REQUEST["procode"];
		
		$sql = "UPDATE itemdetail SET ";
		foreach ($itemdetail as $key=>$value)
		{
			if($key!='itemid')
			{
				// $itemname = 
				//echo $array."<br />";
				//echo $value."<br />";
				$sql .= $key." = '".$value."',";
			}
			
		}
		$sql .= " WHERE itemid = ".$itemdetail['itemid'];
		
		$sql = str_replace(", WHERE"," WHERE",$sql);
//		echo $sql;
		
		$conn = mysql_pconnect($hostname_pdata,$username_pdata,$password_pdata);
		mysql_select_db("pdata");
		if($rs = mysql_query($sql,$conn)  or die(mysql_error()))
		{
			echo "<h2>Update Succeed!</h2>";
			$sql="SELECT * FROM itemdetail WHERE itemid = ".$itemdetail['itemid'];
			$rs = mysql_query($sql,$conn);
			$row = mysql_fetch_assoc($rs);
			$itemdetail = $row;
		}
		else	
			echo "<h2>Failed!</h2>";
	}
	?>
    <form action="item_edit.php" method="post" target="_self" >
      <h2>正在编辑:<?php echo $itemdetail['iname']; ?>
        <input type="submit" class="inputStyle" value="确认更新" />
      </h2>
      <input type="hidden" name="modi" id="modi" value="1" />
      <input type="hidden" name="iname" id="iname" value="<?php echo $itemdetail['iname']; ?>" />
      <input type="hidden" name="itemid" id="itemid" value="<?php echo $itemdetail['itemid']; ?>" />
      <div class="itemstat">
        <table class="itembox">
          <caption>
          <h4>项目规模情况</h4>
          </caption>
          <tr>
            <td><label for="transnum">主变台数</label>
              <input type="text" name="transnum" id="transnum" value="<?php echo $itemdetail['transnum'] ;?>" /></td>
            <td><label for="transcap">主变容量</label>
              <input type="text" name="transcap" id="transcap" value="<?php echo $itemdetail['transcap'] ;?>" /></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><label for="highvolt">高压电压</label>
              <input type="text" name="highvolt" id="highvolt" value="<?php echo $itemdetail['highvolt'] ;?>" /></td>
            <td><label for="midvolt">中压电压</label>
              <input type="text" name="midvolt" id="midvolt" value="<?php echo $itemdetail['midvolt'] ;?>" /></td>
            <td><label for="lowvolt2">低压电压</label>
              <input type="text" name="lowvolt" id="lowvolt2" value="<?php echo $itemdetail['lowvolt'] ;?>" /></td>
          </tr>
          <tr>
            <td><label for="highline">高压出线</label>
              <input type="text" name="highline" id="highline" value="<?php echo $itemdetail['highline'] ;?>" /></td>
            <td><label for="midline3">中压出线</label>
              <input type="text" name="midline" id="midline" value="<?php echo $itemdetail['midline'] ;?>" /></td>
            <td><label for="lowline">低压出线</label>
              <input type="text" name="lowline" id="lowline" value="<?php echo $itemdetail['lowline'] ;?>" /></td>
          </tr>
          <tr>
            <td><label for="capreactive">容性无功补偿</label>
              <input type="text" name="capreactive" id="capreactive" value="<?php echo $itemdetail['capreactive'] ;?>" /></td>
            <td><label for="indreactive">感性无功补偿</label>
              <input type="text" name="indreactive" id="indreactive" value="<?php echo $itemdetail['indreactive'] ;?>" /></td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><label for="starea">围墙内面积</label>
              <input type="text" name="starea" id="starea" value="<?php echo $itemdetail['starea'] ;?>" /></td>
            <td><label for="allbuildarea">全站建筑面积</label>
              <input type="text" name="allbuildarea" id="allbuildarea" value="<?php echo $itemdetail['allbuildarea'] ;?>" /></td>
            <td><label for="mainbuildarea">主控楼建筑面积</label>
              <input type="text" name="mainbuildarea" id="mainbuildarea" value="<?php echo $itemdetail['mainbuildarea'] ;?>" /></td>
          </tr>
          <tr>
            <td colspan="3"><label for="remark">备注</label>
              <input name="remark" type="text" class="doublelengh" id="remark" value="<?php echo $itemdetail['remark'] ;?>" /></td>
          </tr>
          <tr>
            <td><label for="pid">pid</label>
              <input type="text" name="pid" id="pid" value="<?php echo $itemdetail['pid'] ;?>" /></td>
            <td><label for="ptid">ptid</label>
              <input type="text" name="ptid" id="ptid" value="<?php echo $itemdetail['ptid'] ;?>" /></td>
            <td><label for="phid">phid</label>
              <input type="text" name="phid" id="phid" value="<?php echo $itemdetail['phid'] ;?>" /></td>
          </tr>
          
            <td><label for="frm">frm</label>
              <input type="text" name="frm" id="frm" value="<?php echo $itemdetail['frm'] ;?>" /></td>
            <td><label for="stid">stid</label>
              <input type="text" name="stid" id="stid" value="<?php echo $itemdetail['stid'] ;?>" /></td>
            <td><label for="procode">procode</label>
              <input type="text" name="procode" id="procode" value="<?php echo $itemdetail['procode'] ;?>" /></td>
        </table>
      </div>
      <div class="itemcost">
        <table class="itembox">
          <caption>
          <h4>项目投资情况</h4>
          </caption>
          <tr>
            <th scope="col">项目 </th>
            <th scope="col">建筑 </th>
            <th scope="col">设备 </th>
            <th scope="col">安装 </th>
            <th scope="col">其他 </th>
          </tr>
          <tr>
            <th scope="row">主要工程</th>
            <td><input type="text" name="costjzmain1" id="costjzmain1" value="<?php echo $itemdetail['costjzmain1'] ;?>" /></td>
            <td><input type="text" name="costsbmain1" id="costsbmain1" value="<?php echo $itemdetail['costsbmain1'] ;?>" /></td>
            <td><input type="text" name="costazmain1" id="costazmain1" value="<?php echo $itemdetail['costazmain1'] ;?>" /></td>
            <td></td>
          </tr>
          <tr>
            <th scope="row">辅助工程</th>
            <td><input type="text" name="costjzmain2" id="costjzmain2" value="<?php echo $itemdetail['costjzmain2'] ;?>" /></td>
            <td><input type="text" name="costsbmain2" id="costsbmain2" value="<?php echo $itemdetail['costsbmain2'] ;?>" /></td>
            <td><input type="text" name="costazmain2" id="costazmain2" value="<?php echo $itemdetail['costazmain2'] ;?>" /></td>
            <td></td>
          </tr>
          <tr>
            <th scope="row">站址相关</th>
            <td><input type="text" name="costjzmain3" id="costjzmain3" value="<?php echo $itemdetail['costjzmain3'] ;?>" /></td>
            <td></td>
            <td><input type="text" name="costazmain3" id="costazmain3" value="<?php echo $itemdetail['costazmain3'] ;?>" /></td>
            <td></td>
          </tr>
          <tr>
            <th scope="row">其他项目</th>
            <td><input type="text" name="costjzmain4" id="costjzmain4" value="<?php echo $itemdetail['costjzmain4'] ;?>" /></td>
            <td>&nbsp;</td>
            <td><input type="text" name="costazmain4" id="costazmain4" value="<?php echo $itemdetail['costazmain4'] ;?>" /></td>
            <td></td>
          </tr>
          <tr>
            <th scope="row">特殊项目</th>
            <td><input type="text" name="costjzsp" id="costjzsp" value="<?php echo $itemdetail['costjzsp'] ;?>" /></td>
            <td><input type="text" name="costsbex" id="costsbex" value="<?php echo $itemdetail['costsbex'] ;?>" /></td>
            <td><input type="text" name="costazsp" id="costazsp" value="<?php echo $itemdetail['costazsp'] ;?>" /></td>
            <td></td>
          </tr>
          <tr>
            <th scope="row">其他费用</th>
            <td></td>
            <td></td>
            <td></td>
            <td><input type="text" name="costother1" id="costother1" value="<?php echo $itemdetail['costother1'] ;?>" /></td>
          </tr>
          <tr>
            <th scope="row">本体其他</th>
            <td></td>
            <td></td>
            <td></td>
            <td><input type="text" name="costother3" id="costother3" value="<?php echo $itemdetail['costother3'] ;?>" /></td>
          </tr>
          <tr>
            <th scope="row">建场费</th>
            <td></td>
            <td></td>
            <td></td>
            <td><input type="text" name="costclear" id="costclear" value="<?php echo $itemdetail['costclear'] ;?>" /></td>
          </tr>
          <tr>
            <th scope="row">基本预备费</th>
            <td></td>
            <td></td>
            <td></td>
            <td><input type="text" name="costother2" id="costother2" value="<?php echo $itemdetail['costother2'] ;?>" /></td>
          </tr>
          <tr>
            <th scope="row">静态投资</th>
            <td></td>
            <td></td>
            <td></td>
            <td><input type="text" name="coststat" id="coststat" value="<?php echo $itemdetail['coststat'] ;?>" /></td>
          </tr>
          <tr>
            <th scope="row">动态投资</th>
            <td></td>
            <td></td>
            <td></td>
            <td><input type="text" name="costdyn" id="costdyn" value="<?php echo $itemdetail['costdyn'] ;?>" /></td>
          </tr>
        </table>
      </div>
    </form>
</div>
<div id="footer">
  <?php include("../common/footer.php"); ?>
</div>
</body>
</html>